package cn.edu.xmu.oomall.order.microservice;

import cn.edu.xmu.oomall.core.config.OpenFeignConfig;
import cn.edu.xmu.oomall.core.util.Common;
import cn.edu.xmu.oomall.core.util.ReturnObject;
import cn.edu.xmu.oomall.order.microservice.vo.FreightModelRetVo;
import cn.edu.xmu.oomall.order.microservice.vo.OnSaleRetVo;
import cn.edu.xmu.oomall.order.microservice.vo.ProductRetVo;
import cn.edu.xmu.oomall.order.microservice.vo.QuantityVo;
import cn.edu.xmu.privilegegateway.annotation.aop.Audit;
import cn.edu.xmu.privilegegateway.annotation.aop.LoginName;
import cn.edu.xmu.privilegegateway.annotation.aop.LoginUser;
import cn.edu.xmu.privilegegateway.annotation.util.InternalReturnObject;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@FeignClient(name = "goods-service", configuration = OpenFeignConfig.class)
public interface GoodsService {
    /** 获得商品的运费模板 */
    @GetMapping("/shops/{shopId}/products/{id}/freightmodels")
    InternalReturnObject<FreightModelRetVo> getFreightModels(//@RequestHeader("authorization") String authorization,
                                                             @PathVariable Long shopId, @PathVariable Long id);

    /** 获取商品详细信息 */
    @GetMapping("/products/{id}")
    InternalReturnObject<ProductRetVo> getProductDetails(@PathVariable Long id);

    @GetMapping("internal/onsales/{id}")
    InternalReturnObject<OnSaleRetVo> getOnSaleById(@PathVariable Long id);

    @GetMapping("internal/products/{id}/detail")
    InternalReturnObject<ProductRetVo> getProductById(@PathVariable Long id);

    @PutMapping("internal/onsales/{id}/decr")
    InternalReturnObject decreaseOnSale(@PathVariable Long id, @RequestBody QuantityVo quantity);


    @PutMapping("internal/onsales/{id}/incr")
    InternalReturnObject advanceIncrQuantity(@PathVariable Long id, @RequestBody QuantityVo quantity);

    @PutMapping("internal/onsales/{id}/realDecr")
    InternalReturnObject decrQuantity(@PathVariable Long id, @RequestBody QuantityVo quantity);


    @PutMapping("internal/onsales/{id}/realIncr")
    InternalReturnObject incrQuantity(@PathVariable Long id, @RequestBody QuantityVo quantity);


}
